home *** CD-ROM | disk | FTP | other *** search
- Path: news.uni-c.dk!news
- From: maspsr@dou.ou.dk (peter S°rensen)
- Newsgroups: comp.infosystems.www.servers.unix,comp.lang.c
- Subject: Re: Opening a binary file.... (dealing with content-type & WWW)
- Date: 19 Apr 1996 10:58:21 GMT
- Organization: DOU
- Message-ID: <4l7rkd$9a7@news.uni-c.dk>
- References: <317351DE.E7E@draper.com>
- NNTP-Posting-Host: peter.dou.dk
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.93.11
-
- In article <317351DE.E7E@draper.com>, bshalton@draper.com says...
- >
- >Hello,
- >
- >I am trying to establish content-types (mime) based upon the header
- >of the file, rather than relying on the file extension. I have
- >instances where file extensions overlap...ex. .doc (microsoft word),
- >.doc (ascii text document).
- >
- >To be able to set the content-type correctly to launch the
- >appropriate viewer, I am modifying the "file" command to be able to
- >look up by magic types. I have coded the magic type
- >application/msword in the magic file. The modified file program
- >would then open the desired file, and stream it out to the user.
- >
- >Originally I was doing a fork/exec and basically cat'ting the file.
- >This works under Solaris, but for some reason, it doesn't work on
- >SunOS. Plus, I have seen hung processes.
- >
- >I have decided to take out the fork/exec and replace it with a
- >simple open file, read contents, send to browser routine.
- >
- >This is my first cut...
- >
- >
- >
- > fd2=open(entries[0].val,O_RDONLY);
- > for(;;)
- > {
- > if( read(fd2, tbuf, 1) <=0 ) exit(1);
- > printf("%s", tbuf);
- > }
-
- Use the O_BINARY flag to tell the open that this file is binary.
-
- Peter Sorensen/University of Odense,dk/e-mail:maspsr@dou.ou.dk
-
-